package com.kd.crawler.parser.parseres;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Manfred
 *
 */
public class RegexParser implements Parser{

	private int group;
	private Pattern pattern = null; 
	public RegexParser(String regex,int group){
		this.group=group;
		pattern = Pattern.compile(regex);
	}
	
	public String parse(String html) {
		Matcher matcher = pattern.matcher(html);
		if(matcher.find()){
			return matcher.group(group);
		}			
		return null;
	}

}
